﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<InvoiceInvoker.MvcUI.ViewModels.CustomersIndexViewModel>" %>
<%@ Import Namespace="InvoiceInvoker.MvcUI.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Klienci - InvoiceInvoker
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% using (Html.BeginForm()) { %>

    <fieldset>
        <legend>Filtr</legend>
        <%: Html.LabelFor(model => model.Filter.Name) %>:
        <%: Html.TextBoxFor(model => model.Filter.Name) %>
        <input type="submit" value="Filtruj" /> | <%: Html.ActionLink("Wyczyść", "Index") %>
    </fieldset>
    
    <% } %>

    <h3>Klienci (<%: Model.Customers.Count %>):</h3>
    
    <p>
        <%: Html.ActionLink("Dodaj klienta", "Create") %>
    </p>

    <table>
        <tr>
            <th>
                Imię i nazwisko
            </th>
            <th>
                Nazwa firmy
            </th>
            <th>
                Ulica
            </th>
            <th>
                Miasto
            </th>
            <th></th>
        </tr>

    <% foreach (var item in Model.Customers) { %>
    
        <tr>
            <td>
				<% if (item.CustomerName.Length > 40) { %>
					<div title="<%: item.CustomerName %>"><%: Html.Truncate(item.CustomerName, 40) %></div>
                <% } else %>
                <%: item.CustomerName %>
            </td>
            <td>
				<% if (item.CompanyName.Length > 25) { %>
					<div title="<%: item.CompanyName %>"><%: Html.Truncate(item.CompanyName, 25) %></div>
                <% } else %>
                <%: item.CompanyName %>
            </td>
            <td>
				<% if (item.Street.Length > 25) { %>
					<div title="<%: item.Street %>"><%: Html.Truncate(item.Street, 25) %></div>
                <% } else %>
                <%: item.Street %>
            </td>
            <td>
				<% if (item.City.Length > 25) { %>
					<div title="<%: item.City %>"><%: Html.Truncate(item.City, 25) %></div>
                <% } else %>
                <%: item.City %>
            </td>
            <td>
                <%: Html.ActionLink("Edytuj", "Edit", new { id = item.Id }) %> |
                <%: Html.ActionLink("Szczegóły", "Details", new { id = item.Id }) %> |
                <%: Html.ActionLink("Usuń", "Delete", new { id = item.Id })%>
            </td>
        </tr>
    
    <% } %>

    </table>

</asp:Content>

